// 一个移动无符号int的函数，如果为正数左移，为负数右移
#include <stdio.h>

unsigned int shift(unsigned int value, int n){
	if(n > 0) // 左移
		value <<= n;
	else      // 右移
		value >>= -n;
	
	return value;
}

int main(void){
	unsigned int w1 = 0177777u, w2 = 0444u;
	unsigned int shift(unsigned int value, int n);
	
	printf("%o\t%o\n", shift(w1, 5), w1 << 5);
	printf("%o\t%o\n", shift(w1, -6), w1 >> 6);
	printf("%o\t%o\n", shift(w2, 0), w2 >> 0);
	printf("%o\n", shift(shift(w1, -3), 3)); //将低3位设置为0
	
	return 0;
}
